/*
 * @Author: 肖思汗 
 * @Date: 2025-06-10 11:53:23 
 * @Last Modified by: 肖思汗
 * @Last Modified time: 2025-07-06 12:37:12
 */

import Api from "src/api/Api";
import { ReceiveAddress } from "types/type";

//地址管理
class AddressManageApi extends Api {

    constructor() {
        super();
    }

    //查询收货地址
    getlistMyAddress() {
        return this._get("/my/address/listMyAddress", { pageNum: 1, pageSize: 9999 });
    }

    //新增收货地址
    add(data: Omit<ReceiveAddress, "appAddressId">) {
        return this._post("/my/address/addMyAddress", data);
    }

    //修改收货地址
    update(data: ReceiveAddress) {
        return this._post("/my/address/editMyAddress", data);
    }

    //删除收货地址
    delete(addressId: number | string) {
        return this._get('/my/address/delMyAddress', { addressId });
    }

    //获取单个收货地址
    async getById(addressId: number | string): Promise<ReceiveAddress> {
        const res = await this._get("/my/address/getMyAddressById", { addressId });
        return res.data;
    }


}

const addressManageApi = new AddressManageApi();

export default addressManageApi;